package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainOrderPaymentlogs;
import com.ktgj.train.service.ITrainOrderPaymentlogsService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单付款日志Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/paymentlogs")
public class TrainOrderPaymentlogsController extends BaseController
{
    @Autowired
    private ITrainOrderPaymentlogsService trainOrderPaymentlogsService;

    /**
     * 查询订单付款日志列表
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainOrderPaymentlogs trainOrderPaymentlogs)
    {
        startPage();
        List<TrainOrderPaymentlogs> list = trainOrderPaymentlogsService.selectTrainOrderPaymentlogsList(trainOrderPaymentlogs);
        return getDataTable(list);
    }

    /**
     * 导出订单付款日志列表
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:export")
    @Log(title = "订单付款日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainOrderPaymentlogs trainOrderPaymentlogs) throws IOException
    {
        List<TrainOrderPaymentlogs> list = trainOrderPaymentlogsService.selectTrainOrderPaymentlogsList(trainOrderPaymentlogs);
        ExcelUtil<TrainOrderPaymentlogs> util = new ExcelUtil<TrainOrderPaymentlogs>(TrainOrderPaymentlogs.class);
        util.exportExcel(response, list, "订单付款日志数据");
    }

    /**
     * 获取订单付款日志详细信息
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:query")
    @GetMapping(value = "/{logid}")
    public AjaxResult getInfo(@PathVariable("logid") Long logid)
    {
        return AjaxResult.success(trainOrderPaymentlogsService.selectTrainOrderPaymentlogsById(logid));
    }

    /**
     * 新增订单付款日志
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:add")
    @Log(title = "订单付款日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainOrderPaymentlogs trainOrderPaymentlogs)
    {
        return toAjax(trainOrderPaymentlogsService.insertTrainOrderPaymentlogs(trainOrderPaymentlogs));
    }

    /**
     * 修改订单付款日志
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:edit")
    @Log(title = "订单付款日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainOrderPaymentlogs trainOrderPaymentlogs)
    {
        return toAjax(trainOrderPaymentlogsService.updateTrainOrderPaymentlogs(trainOrderPaymentlogs));
    }

    /**
     * 删除订单付款日志
     */
    @PreAuthorize(hasPermi = "train:paymentlogs:remove")
    @Log(title = "订单付款日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logids}")
    public AjaxResult remove(@PathVariable Long[] logids)
    {
        return toAjax(trainOrderPaymentlogsService.deleteTrainOrderPaymentlogsByIds(logids));
    }
}
